package com.red.star.wechat.work.site;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.red.star.wechat.data.entity.Mall;
import com.red.star.wechat.work.entity.TableContainer;
import com.red.star.wechat.work.utils.CommonUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author nofish.yan@gmail.com
 * @date 2018/1/26.
 */
@Controller
public class IndexController {

    @RequestMapping("/table")
    public String table(){
        return "table";
    }

    @RequestMapping("/mallDetail")
    public String mallDetail(){
        return "mallDetail";
    }

    @RequestMapping("/tableList")
    @ResponseBody
    public ResponseEntity<?> infoList(Mall mall){
        Page<?> page  = PageHelper.startPage(mall.getPage(), mall.getRows());
        List<Mall> mallList = new ArrayList<Mall>();
        Mall mall1 = new Mall();
        mall1.setAddress("商户");
        mallList.add(mall1);
        Mall mall2 = new Mall();
        mall2.setAddress("shang");
        mallList.add(mall2);
        TableContainer tableContainer = CommonUtil.backTableContainer(mallList,page);
        return new ResponseEntity<>(tableContainer, HttpStatus.OK);
    }
}
